package com.dyrj.pig.controller;

import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.RequestMapping;
import com.dyrj.vo.PageResultMsg;
import com.dyrj.vo.ResultMsg;
import com.dyrj.pig.service.ITRecordPayService;
import com.dyrj.pig.bean.TRecordPay;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import org.springframework.stereotype.Controller;
import org.springframework.web.context.request.WebRequest;

/**
 * <p>
 * 充值记录
状态0未发起1付款成功2分账成功-1分账失败-2付款失败 前端控制器
 * </p>
 *
 * @author admin
 * @since 2020-10-02
 */
@Controller
@RequestMapping("/pig/t-record-pay")
public class TRecordPayController {

    @Resource
    private ITRecordPayService service;

    @InitBinder
    public void initBinder(WebDataBinder binder, WebRequest request) {
        // 转换日期格式
        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
        binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));

    }

    @GetMapping("/index")
    public String index(ModelMap map) {
    return "pig/index_t-record-pay";
    }

    /**
    * @Title: table
    * @Description: (表格数据) 列表
    * @return PageInfo<TRecordPay>    返回类型
    */
    @GetMapping("/table")
    @ResponseBody
    public PageResultMsg table(TRecordPay record) {
        return service.table(record);
    }

    /**
    * @Title: add
    * @Description: (新增)
    * @param record
    * @return ResultMsg    返回类型
    */
//    @PostMapping("/")
//    @ResponseBody
//    public ResultMsg add(TRecordPay record) {
//        return service.add(record);
//    }

    /**
    * @Title: info
    * @Description: (详情)
    * @param id
    * @return TRecordPay    返回类型
    */
    @GetMapping("/{id}")
    @ResponseBody
    public TRecordPay info(@PathVariable String id) {
        return service.info(id);
    }

    /**
    * @Title: update
    * @Description: (更新)
    * @param record
    * @return ResultMsg    返回类型
    */
//    @PutMapping("/")
//    @ResponseBody
//    public ResultMsg update(TRecordPay record) {
//        return service.update(record);
//    }

    /**
    * @Title: delete
    * @Description: (删除)
    * @param id
    * @return ResultMsg    返回类型
    */
//    @DeleteMapping("/{id}")
//    @ResponseBody
//    public ResultMsg delete(@PathVariable String id) {
//        return service.delete(id);
//    }


}
